package user_service

import (
	"time"

	"bird/internal/api/repository/db_repo/user_info_repo"
	"bird/internal/pkg/core"
)

type RegisterData struct {
	PhoneNo              string
	RegisterType         int
	ProfilePhotoUrl      string
	UserName             string
	Gender               int
	IdCardUrl            string
	Birth                int64
	Recommenders         string
	VehLicenseUrl        string
	VehLicenseExpire     int64
	DriverLicenseUrl     string
	DriverLicenseExpire  int64
	InsuranceUrl         string
	InsuranceExpire      int64
	QualificationCertUrl string
}

func (s *service) RegisterBasic(ctx core.Context, userData *RegisterData) (id int32, err error) {
	model := user_info_repo.NewModel()
	model.ProfilePhotoUrl = userData.ProfilePhotoUrl
	model.PhoneNo = userData.PhoneNo
	model.UserName = userData.UserName
	model.Gender = int32(userData.Gender)
	model.IdCardUrl = userData.IdCardUrl
	model.Birth = time.Unix(userData.Birth, 0)
	model.Recommenders = userData.Recommenders
	//默认未审核
	//model.Status = 2
	model.Role = int32(userData.RegisterType) // 0:发货人，1：司机

	//写入user_info表
	id, err = model.Create(s.db.GetDbW().WithContext(ctx.RequestContext()))

	return
}
